package com.yanqu.road.server.cmd.activity.dragonboatrace;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.dragonboatrace.DragonBoatRaceProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.dragonboatrace.DragonBoatRaceMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_DRAGONBOATRACE_GET_VOYAGE_RECORD, desc = "赛龙舟查看航行记录")
public class DragonBoatRaceGetVoyageRecordCmd extends AbstractCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = DragonBoatRaceMgr.getActivityShowStatus(player);
        if(ret != 0){
            return;
        }

        DragonBoatRaceProto.DragonBoatRaceGetVoyageRecordGameToCrossMsg.Builder gameToCrossMsg = DragonBoatRaceProto.DragonBoatRaceGetVoyageRecordGameToCrossMsg.newBuilder();
        gameToCrossMsg.setActivityId(DragonBoatRaceMgr.getActivityInfo().getActivityId());
        gameToCrossMsg.setUnionId(player.getUserInfo().getUnionUid());
        player.sendPacket(CrossProtocol.C2_DRAGONBOATRACE_GET_VOYAGE_RECORD, gameToCrossMsg);

    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            DragonBoatRaceProto.DragonBoatRaceGetVoyageRecordRespMsg.Builder builder = DragonBoatRaceProto.DragonBoatRaceGetVoyageRecordRespMsg.newBuilder();
            builder.setRet(ret);
            player.sendPacket(ClientProtocol.U_DRAGONBOATRACE_GET_VOYAGE_RECORD, builder);
        }
    }
}
